
<template>
<div class="m-homeremd">
    <h2 class="remd_tl">编辑推荐</h2>
    <div class="remd_songs">
      <div class="remd_ul" >
        <div href="" class="remd_li" v-for="item in data" :key="item.id" @click="selectPlayList(item)">
          <div class="remd_img">
            <img :src="item.picUrl" alt="" class="u-img">
            <span class="u-earp remd_lnum " >{{item.playCount}}</span>
          </div>
          <p class="remd_text">{{item.name}}</p>
        </div>
      </div>
    </div>
    <h2 class="remd_tl">最新音乐</h2>
    <div class="remd_newsg">
      <div class="m-sglst">
        <a href="" class="m-sgitem" v-for="item in newData" :key="item.id">
          <div class="sgfr f-bd f-bd-btm">
            <div class="sgchfl">
              <div class="f-thide sgtl">{{item.name}}</div>
              <div class="f-thide sginfo">
                <i class="u-hmsprt sghot"></i>
               {{item.song.artists[0].name}}
              </div>

            </div>
            <div class="sgchfr">
              <span class="u-hmsprt sgchply"></span>
            </div>
          </div>
        </a>
      </div>
    </div>
   </div>
</template>
<script>


import axios from "axios";

export default {
  data() {
    return {
      data: [],
      newData:[],
    };
  },

  created() {
   this.getRecommendBanner();
   this.getNewSongList();
  },

  methods: {
   getRecommendBanner() {
      axios
        .get("http://171.220.242.237:3001/personalized?limit=6", "")
        .then((res) => {
           console.log(res);
          this.data = res.data.result;
          console.log(this.data)
        })
        .catch((err) => {
          console.error(err);
        });
    },
    getNewSongList(){
      axios
       .get("http://171.220.242.237:3001/personalized/newsong")
       .then((res) => {
           console.log(res);
          this.newData = res.data.result;
          console.log(this.newData)
        })
        .catch((err) => {
          console.error(err);
        });
    },
    selectPlayList(item){
      const id=item.id
      console.log(id)
      this.$router.push({
        name:'PlayListDetail',
        params :{id}
      })
    }
  }
};
</script>

<style scoped>
.m-homeremd {
    padding-top: 20px;
}
.m-homeremd .remd_tl {
    position: relative;
    padding-left: 9px;
    text-align: left;
    margin-bottom: 14px;
    font-size: 17px;
    height: 20px;
    line-height: 20px;
}
.m-homeremd .remd_tl:after {
    content: " ";
    position: absolute;
    left: 0;
    top: 50%;
    margin-top: -9px;
    width: 2px;
    height: 16px;
    background-color: #d33a31;
}
.remd_songs {
    position: relative;
    padding-bottom: 24px;
}
.m-homeremd .remd_ul {
    display: flex;
    flex-wrap: wrap;
}
.m-homeremd .remd_li:first-child {
    padding-left: 0;
    padding-right: 2px;
}
.m-homeremd .remd_li {
    display: block;
    margin-bottom: 16px;
    float: left;
    width: 33.3%;
    padding-left: 1px;
    padding-right: 1px;
    box-sizing: border-box;
    }
 .remd_img {
    position: relative;
    padding-bottom: 100%;
} 
.m-homeremd .remd_img>.u-img {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    z-index: 1;
}  
.u-img {
    width: 100%;
    vertical-align: middle;
}
.m-homeremd .remd_lnum {
    position: absolute;
    right: 5px;
    top: 2px;
    z-index: 113;
    padding-left: 13px;
    color: #fff;
    font-size: 12px;
    background-position: 0;
    background-repeat: no-repeat;
    background-size: 11px 10px;
    text-shadow: 1px 0 0 rgb(0 0 0 / 15%);
}
.u-earp {
    background-image: url(erji.svg);
}
.m-homeremd .remd_img:after {
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 20px;
    z-index: 112;
    background-image: -webkit-linear-gradient(top,rgba(0,0,0,.2),rgba(0,0,0,0));
    background-image: linear-gradient(
180deg
,rgba(0,0,0,.2),rgba(0,0,0,0));
}
.m-homeremd .remd_text {
    overflow: hidden;
    padding: 0px 2px 0 0px;
    min-height: 30px;
    line-height: 1.2;
    font-size: 13px;
}
.m-homeremd .remd_newsg {
    position: relative;
    min-height: 20px;
}.m-sglst {
    position: relative;
}.m-sgitem {
    padding-left: 10px;

}
.m-sgitem, .m-sgitem .sgfl {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}
.m-sgitem .sgfr {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    position: relative;
}
.f-bd {
    position: relative;
}
.m-sgitem .sgchfl {
    padding: 6px 0;
    width: 0;
}
.m-sgitem .sgchfl, .m-sgitem .sgfr {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 auto;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
}
.m-sgitem .sgtl {
    font-size: 17px;
    text-align: left;
}
.f-thide {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
}
.m-sgitem .sginfo {
    font-size: 12px;
    color: #888;
    text-align: left;
}
.m-sgitem .sghot {
    display: inline-block;
    width: 12px;
    height: 8px;
    margin-right: 4px;
}
.u-hmsprt {
    background: url(//s3.music.126.net/mobile-new/img/index_icon_2x.png?5207a28…=) no-repeat;
    background-size: 166px 97px;
}
.m-sgitem .sgchfr {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 0 10px;
}
.m-sgitem .sgchply {
    display: inline-block;
    width: 22px;
    height: 22px;
    background-position: -24px 0;
}
</style>